package com.jwaoo.chat.viewholder;

import com.jwaoo.chat.ChatConstants;
import com.jwaoo.chat.Message;

import java.util.ArrayList;
import java.util.List;

/**
 * 消息项展示ViewHolder工厂类。
 */
public class MsgViewHolderFactory {
    public static Class<? extends MsgViewHolderBase> getViewHolderByType(Message message) {
        switch (message.getMsgtype()){
            case ChatConstants.text:
                return MsgViewHolderText.class;
            case ChatConstants.tip:
                return MsgViewHolderUnknown.class;
            case ChatConstants.audio:
                return MsgViewHolderAudio.class;
            case ChatConstants.video:
                return MsgViewHolderVideo.class;
            case ChatConstants.image:
                return MsgViewHolderPicture.class;
            case ChatConstants.snap:
                return MsgViewHolderSnapChat.class;
            case ChatConstants.audio_chat:
            case ChatConstants.video_chat:
                return MsgViewHolderAVChat.class;
            default:
                return MsgViewHolderUnknown.class;
        }
    }

    public static List<Class<? extends MsgViewHolderBase>> getAllViewHolders() {
        List<Class<? extends MsgViewHolderBase>> list = new ArrayList<>();
        list.add(MsgViewHolderUnknown.class);
        list.add(MsgViewHolderText.class);
        list.add(MsgViewHolderVideo.class);
        list.add(MsgViewHolderAudio.class);
        list.add(MsgViewHolderPicture.class);
        list.add(MsgViewHolderSnapChat.class);
        list.add(MsgViewHolderAVChat.class);
        return list;
    }
}
